﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using WCSY.BLL;

public partial class FormSec_RoleUserIframe : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack){
            DataTable urDt = Mg_urRelationManager.getAllUR("");
            gvBind(urDt);
        }
    }

    public void gvBind(DataTable dt) {
        this.GridView1.DataSource = dt;
        this.GridView1.DataBind();
    }
    //绑定行
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string roleid = e.Row.Cells[0].Text.ToString();
            string roleName = e.Row.Cells[1].Text.ToString();
            string userid = e.Row.Cells[2].Text.ToString();
            string userName = e.Row.Cells[3].Text.ToString();
            string item = roleid + "~" + roleName + "~" + userid + "~" + userName;
            e.Row.Attributes.Add("ondblclick", "parent.window.sed('" + item + "')");
            e.Row.Attributes.Add("onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#Efefef'}");//当鼠标停留时更改背景色
            e.Row.Attributes.Add("onmouseout", "if(this!=prevselitem){this.style.backgroundColor='#ffffff'}");//当鼠标移开时还原背景色
            //有复选框时用该语句
            //e.Row.Attributes.Add("onclick", e.Row.ClientID.ToString() + ".checked=true;selectx(this)");
            //没有复选框
            e.Row.Attributes.Add("onclick", "selectx(this)");
        }
    }
    //条件查询
    protected void btnTrue_Click(object sender, EventArgs e)
    {
        string roleName = txtRoleName.Text.Trim();
        string userName = txtUserName.Text.Trim();
        string where = "";
        if(!roleName.Equals("")){
            where += " mg_role.roleName like '%"+roleName+"%' ";
        }
        if(!userName.Equals("")){
            where += " and mg_user.userName like '%" + userName + "%'";
        }
        DataTable urDt = Mg_urRelationManager.getAllUR(where);
        gvBind(urDt);
    }
}
